<?php

namespace S\WeChat\Util;

use S\Request;

class Url
{
    const QUERY_OFFICIAL_ACCOUNT = '_oa_';

    public static function build($official_account, $path = '', array $query = [], $anchor = '', $base = APP_HOST_URL)
    {
        $query[static::QUERY_OFFICIAL_ACCOUNT] = $official_account;
        $path                                  = trim($path, '\\/');
        $params                                = http_build_query($query);
        $anchor                                = $anchor ? "#{$anchor}" : '';
        return "{$base}/{$path}?{$params}{$anchor}";
    }

    public static function getOfficialAccount($default = '')
    {
        return Request::get(static::QUERY_OFFICIAL_ACCOUNT, $default);
    }

}